<?php
/**
 * Yii command line script file.
 *
 * This script is meant to be run on command line to execute
 * one of the pre-defined console commands.
 *
 * @author Qiang Xue <qiang.xue@gmail.com>
 * @link http://www.yiiframework.com/
 * @copyright Copyright &copy; 2008-2011 Yii Software LLC
 * @license http://www.yiiframework.com/license/
 * @version $Id: yiic.php 2799 2011-01-01 19:31:13Z qiang.xue $
 */


if(PHP_SAPI != 'cli'){
	echo "CLI only\r\n";
	die;
}


define('SYS_HACKER_CONSOLE', false);
// fix for fcgi
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
defined('YII_DEBUG') or define('YII_DEBUG',true);

require dirname(__FILE__).'/../../../../config/loader.php';

if(!class_exists('Engine',false)){
	require Config::Get('path.root.engine').'/classes/Engine.class.php';
}
$E = Engine::getInstance();
$E->Init();


$app = $E->PluginYii_Yii_App();

$app->commandRunner->addCommands(YII_PATH.'/cli/commands');
$env = @getenv('YII_CONSOLE_COMMANDS');
if(!empty($env)){
	$app->commandRunner->addCommands($env);
}
//$app=Yii::createConsoleApplication(array('basePath'=>dirname(__FILE__).'/cli'));

$app->run();